import {
  setItem,
  getItem
} from '@/utils/storage'
// import refreshToken from '@/api/login'

const key = 'TOKEN_JZ'

const state = {
  token: getItem(key) || {}
}

const mutations = {
  setToken(state, token) {
    state.token = token
    setItem(key, token)
  },
  removeToken(state) {
    state.token = {}
    setItem(key, '')
  }
  // refreshToken(state, newToken) {
  //   state.token = newToken
  //   setItem(key, newToken)
  // }
}

const actions = {
  // async refreshToken(context) {
  //   const newToken = await refreshToken()
  //   context.commit('refreshToken', newToken.data)
  // }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
